// 1. 导入 自定义好的 request 请求函数
import request from '../utils/request'

import store from '@/store'

// 2. 定义接口函数 - 首页 - 获取用户选择的频道
const getUserListApi = () => {
    return request({
        method: 'GET',
        url: '/v1_0/user/channels',
        headers: {
            Authorization: `Bearer ${store.state.token}`
        }
    })
}

// 首页 - 获取文章列表
const getArticleListAPI = ({ channelId, timestamp = Date.now() + '' }) => {
        return request({
            method: 'GET',
            url: '/v1_0/articles',
            params: {
                channel_id: channelId,
                timestamp
            }
        })
    }
    // 首页 - 文章_不感兴趣接口
const artDisLikeAPI = ({ artId }) => {
    return request({
        method: 'POST',
        url: '/v1_0/article/dislikes',
        headers: {
            Authorization: `Bearer ${store.state.token}`
        },
        data: {
            target: artId
        }
    })
}

// 首页 - 文章_举报
const arReportsAPI = ({ artId, type, remark }) => {
    return request({

        url: '/v1_0/article/reports',
        method: 'POST',
        headers: {
            Authorization: `Bearer ${store.state.token}`
        },
        data: {
            target: artId,
            type: type,
            remark: type === '0' ? remark : remark || null
        }
    })
}

export {
    getUserListApi,
    getArticleListAPI,
    artDisLikeAPI,
    arReportsAPI,
}